package com.pig4cloud.pigx.knowledge.support.constant;

import lombok.Getter;

/**
 * Mi IoT 服务枚举
 *
 * @author lengleng
 * @date 2024/12/22
 * <p>
 * 0  switch  turn_off
 * 1 switch  turn_on
 */
public enum MiIotServiceEnums {

    SWITCH_TURN_OFF(0, "switch", "turn_off"),

    SWITCH_TURN_ON(1, "switch", "turn_on");


    private int code;

    @Getter
    private String domain;

    @Getter
    private String service;


    MiIotServiceEnums(int code, String domain, String service) {
        this.code = code;
        this.domain = domain;
        this.service = service;
    }

    /**
     * 按代码获取枚举
     *
     * @param code 法典
     * @return {@link MiIotServiceEnums }
     */
    public static MiIotServiceEnums getEnumByCode(int code) {
        for (MiIotServiceEnums value : MiIotServiceEnums.values()) {
            if (value.code == code) {
                return value;
            }
        }
        return null;
    }
}
